﻿$(document).ready(function () {
    $.each($(".promotion"), function () {
        $(this).bindPromotion();
    })
    
    $(".msg-box .date").bindDate();
});

$.fn.extend({
    bindPromotion: function () {
        var container = $(this[0]);
        
        container.find(".btn-qq, .btn-msn").click(function (ev) {
            
        });
        
        container.find("a").click(function (ev) {
            ev.stopPropagation();
        });
        
        container.click(function () {
            createDetailDialog(container.attr("postPath"));
        })
        .mouseenter(function (ev) {
            $(this).addClass("promotion-hover");
            $(this).find(".btn-view").show();
        })
        .mouseleave(function () {
            $(this).removeClass("promotion-hover");
             $(this).find(".btn-view").hide();
        });
    },
    
    bindDate: function () {
        var strDate = "今天是 ";
        
        var d=new Date()
        
        strDate += d.getFullYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate() + "日 ";
        
        var weekday=new Array(7)
        weekday[0]="星期日"
        weekday[1]="星期一"
        weekday[2]="星期二"
        weekday[3]="星期三"
        weekday[4]="星期四"
        weekday[5]="星期五"
        weekday[6]="星期六"

        strDate += weekday[d.getDay()];
        
        $(this[0]).html(strDate);
    }
});